package com.android.jianboshi.dialog;

import android.view.View;
import android.widget.TextView;

import androidx.fragment.app.FragmentActivity;

import com.android.baselibrary.dialog.BaseDialogFragment;
import com.android.baselibrary.util.Util;
import com.android.jianboshi.R;

import java.util.Map;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * 测拳速
 */

public class Boxing_SpeedResult_DialogFragment extends BaseDialogFragment {

    @BindView(R.id.tv_title)
    TextView tv_title;
    @BindView(R.id.tv_title1)
    TextView tv_title1;
    @BindView(R.id.tv_title2)
    TextView tv_title2;
    @BindView(R.id.tv_content1)
    TextView tv_content1;
    @BindView(R.id.tv_content2)
    TextView tv_content2;

    int hits;
    double kcal;

    public static final String Param_Hits = "Param_Hits";
    public static final String Param_Kcal = "Param_Kcal";

    @Override
    protected int getLayoutId() {
        return R.layout.dialog_boxing_speed_result;
    }

    @Override
    protected void initData() {
        tv_title1.setText(getString(R.string.freestyle_tips_times));
        tv_title2.setText(getString(R.string.freestyle_tips_kal));

        tv_title.setText(getString(R.string.freestyle_tips_title_history));

        tv_content1.setText("" + hits +" "+ getString(R.string.freestyle_tips_unit_times));
        tv_content2.setText("" + Util.numDecimalFormat(kcal + "", 1)+ " Kcal");
    }

    @Override
    protected void initView() {

    }

    @Override
    protected boolean setCanceledOnTouchBACK() {
        return true;
    }

    @Override
    protected int getShowDirection() {
        return BaseDialogFragment.Direction_FadeIn;
    }

    @Override
    public void setData(Map<String, Object> params) {
        if (params != null) {
            hits = (int) params.get(Boxing_SpeedResult_DialogFragment.Param_Hits);
            kcal = (double) params.get(Boxing_SpeedResult_DialogFragment.Param_Kcal);
        }
    }

    public static BaseDialogFragment showDialog(FragmentActivity activity, Map<String, Object> params) {
        Boxing_SpeedResult_DialogFragment dialogFragment = new Boxing_SpeedResult_DialogFragment();
        dialogFragment.setData(params);
        dialogFragment.show(activity.getSupportFragmentManager(), "");
        return dialogFragment;
    }


    @OnClick({R.id.csb_ok})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.csb_ok:  //确定
                dismissWithAnim();
                break;
        }
    }


}
